<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 33. Boost.Proto</title>
<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)">
<link rel="prev" href="boost/property_tree/xml_parser/write_1_3_33_10_11_1_1_1_4.html" title="Function template write_xml">
<link rel="next" href="proto/users_guide.html" title="Users' Guide">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
<td align="center"><a href="../../index.html">Home</a></td>
<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost/property_tree/xml_parser/write_1_3_33_10_11_1_1_1_4.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="proto/users_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="chapter">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="proto"></a>Chapter 33. Boost.Proto</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Eric</span> <span class="surname">Niebler</span>
</h3></div></div>
<div><p class="copyright">Copyright © 2008 Eric Niebler</p></div>
<div><div class="legalnotice">
<a name="proto.legal"></a><p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></div>
</div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl class="toc">
<dt><span class="section"><a href="proto.html#boost_proto.preface">Preface</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html">Users' Guide</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.getting_started">Getting Started</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.front_end">Fronts Ends: Defining
      Terminals and Non-Terminals of Your EDSL</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.intermediate_form">Intermediate
      Form: Understanding and Introspecting Expressions</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.back_end">Back Ends: Making Expression
      Templates Do Useful Work</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.examples">Examples</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.resources">Background and Resources</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.glossary">Glossary</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="proto/reference.html">Reference</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="proto/reference.html#proto.concepts">Concepts</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#proto.reference.classes">Classes</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#proto.reference.functions">Functions</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.args_hpp">Header &lt;boost/proto/args.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.core_hpp">Header &lt;boost/proto/core.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.debug_hpp">Header &lt;boost/proto/debug.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.deep_copy_hpp">Header &lt;boost/proto/deep_copy.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.domain_hpp">Header &lt;boost/proto/domain.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.eval_hpp">Header &lt;boost/proto/eval.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.expr_hpp">Header &lt;boost/proto/expr.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.extends_hpp">Header &lt;boost/proto/extends.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional_hpp">Header &lt;boost/proto/functional.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion_hpp">Header &lt;boost/proto/functional/fusion.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.at_hpp">Header &lt;boost/proto/functional/fusion/at.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.pop_back_hpp">Header &lt;boost/proto/functional/fusion/pop_back.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.pop_front_hpp">Header &lt;boost/proto/functional/fusion/pop_front.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.push_back_hpp">Header &lt;boost/proto/functional/fusion/push_back.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.push_front_hpp">Header &lt;boost/proto/functional/fusion/push_front.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.reverse_hpp">Header &lt;boost/proto/functional/fusion/reverse.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.begin_hpp">Header &lt;boost/proto/functional/range/begin.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.empty_hpp">Header &lt;boost/proto/functional/range/empty.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.end_hpp">Header &lt;boost/proto/functional/range/end.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.rbegin_hpp">Header &lt;boost/proto/functional/range/rbegin.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.rend_hpp">Header &lt;boost/proto/functional/range/rend.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.size_hpp">Header &lt;boost/proto/functional/range/size.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.std_hpp">Header &lt;boost/proto/functional/std.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.std.iterator_hpp">Header &lt;boost/proto/functional/std/iterator.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.std.utility_hpp">Header &lt;boost/proto/functional/std/utility.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.fusion_hpp">Header &lt;boost/proto/fusion.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.generate_hpp">Header &lt;boost/proto/generate.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.literal_hpp">Header &lt;boost/proto/literal.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.make_expr_hpp">Header &lt;boost/proto/make_expr.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.matches_hpp">Header &lt;boost/proto/matches.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.operators_hpp">Header &lt;boost/proto/operators.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.proto_hpp">Header &lt;boost/proto/proto.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.proto_fwd_hpp">Header &lt;boost/proto/proto_fwd.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.proto_typeof_hpp">Header &lt;boost/proto/proto_typeof.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.repeat_hpp">Header &lt;boost/proto/repeat.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.tags_hpp">Header &lt;boost/proto/tags.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.traits_hpp">Header &lt;boost/proto/traits.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform_hpp">Header &lt;boost/proto/transform.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.arg_hpp">Header &lt;boost/proto/transform/arg.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.call_hpp">Header &lt;boost/proto/transform/call.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.default_hpp">Header &lt;boost/proto/transform/default.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.env_hpp">Header &lt;boost/proto/transform/env.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.fold_hpp">Header &lt;boost/proto/transform/fold.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.fold_tree_hpp">Header &lt;boost/proto/transform/fold_tree.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.impl_hpp">Header &lt;boost/proto/transform/impl.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.integral_c_hpp">Header &lt;boost/proto/transform/integral_c.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.lazy_hpp">Header &lt;boost/proto/transform/lazy.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.make_hpp">Header &lt;boost/proto/transform/make.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.pass_through_hpp">Header &lt;boost/proto/transform/pass_through.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.when_hpp">Header &lt;boost/proto/transform/when.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context_hpp">Header &lt;boost/proto/context.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context.callable_hpp">Header &lt;boost/proto/context/callable.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context.default_hpp">Header &lt;boost/proto/context/default.hpp&gt;</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context.null_hpp">Header &lt;boost/proto/context/null.hpp&gt;</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="proto/appendices.html">Appendices</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.release_notes">Appendix A: Release
      Notes</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.history">Appendix B: History</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.rationale">Appendix C: Rationale</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.implementation">Appendix D: Implementation
      Notes</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.acknowledgements">Appendix E:
      Acknowledgements</a></span></dt>
</dl></dd>
</dl>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_proto.preface"></a><a class="link" href="proto.html#boost_proto.preface" title="Preface">Preface</a>
</h2></div></div></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="quote">“<span class="quote">There are more things in heaven and earth, Horatio, than are dreamt
        of in your philosophy.</span>”</span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="bold"><strong><span class="emphasis"><em>-- William Shakespeare</em></span></strong></span>
      </p></blockquote></div>
<h4>
<a name="boost_proto.preface.h0"></a>
      <span class="phrase"><a name="boost_proto.preface.description"></a></span><a class="link" href="proto.html#boost_proto.preface.description">Description</a>
    </h4>
<p>
      Proto is a framework for building Embedded Domain-Specific Languages in C++.
      It provides tools for constructing, type-checking, transforming and executing
      <span class="emphasis"><em>expression templates</em></span><a href="#ftn.boost_proto.preface.f0" class="footnote" name="boost_proto.preface.f0"><sup class="footnote">[33]</sup></a>. More specifically, Proto provides:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          An expression tree data structure.
        </li>
<li class="listitem">
          A mechanism for giving expressions additional behaviors and members.
        </li>
<li class="listitem">
          Operator overloads for building the tree from an expression.
        </li>
<li class="listitem">
          Utilities for defining the grammar to which an expression must conform.
        </li>
<li class="listitem">
          An extensible mechanism for immediately executing an expression template.
        </li>
<li class="listitem">
          An extensible set of tree transformations to apply to expression trees.
        </li>
</ul></div>
<h4>
<a name="boost_proto.preface.h1"></a>
      <span class="phrase"><a name="boost_proto.preface.motivation"></a></span><a class="link" href="proto.html#boost_proto.preface.motivation">Motivation</a>
    </h4>
<p>
      Expression Templates are an advanced technique that C++ library developers
      use to define embedded mini-languages that target specific problem domains.
      The technique has been used to create efficient and easy-to-use libraries for
      linear algebra as well as to define C++ parser generators with a readable syntax.
      But developing such a library involves writing an inordinate amount of unreadable
      and unmaintainable template mumbo-jumbo. Boost.Proto eases the development
      of <a class="link" href="proto/users_guide.html#boost_proto.users_guide.glossary.edsl">domain-specific embedded
      languages (EDSLs)</a>. Use Proto to define the primitives of your mini-language
      and let Proto handle the operator overloading and the construction of the expression
      parse tree. Immediately evaluate the expression tree by passing it a function
      object. Or transform the expression tree by defining the grammar of your mini-language,
      decorated with an assortment of tree transforms provided by Proto or defined
      by you. Then use the grammar to give your users short and readable syntax errors
      for invalid expressions! No more mumbo-jumbo -- an expression template library
      developed with Proto is declarative and readable.
    </p>
<p>
      In short, Proto is an EDSL for defining EDSLs.
    </p>
<h4>
<a name="boost_proto.preface.h2"></a>
      <span class="phrase"><a name="boost_proto.preface.how_to_use_this_documentation"></a></span><a class="link" href="proto.html#boost_proto.preface.how_to_use_this_documentation">How
      to Use This Documentation</a>
    </h4>
<p>
      This documentation makes use of the following naming and formatting conventions.
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          Code is in <code class="computeroutput"><span class="identifier">fixed</span> <span class="identifier">width</span>
          <span class="identifier">font</span></code> and is syntax-highlighted.
        </li>
<li class="listitem">
          Replaceable text that you will need to supply is in <em class="replaceable"><code>italics</code></em>.
        </li>
<li class="listitem">
          If a name refers to a free function, it is specified like this: <code class="computeroutput"><span class="identifier">free_function</span><span class="special">()</span></code>;
          that is, it is in code font and its name is followed by <code class="computeroutput"><span class="special">()</span></code>
          to indicate that it is a free function.
        </li>
<li class="listitem">
          If a name refers to a class template, it is specified like this: <code class="computeroutput"><span class="identifier">class_template</span><span class="special">&lt;&gt;</span></code>;
          that is, it is in code font and its name is followed by <code class="computeroutput"><span class="special">&lt;&gt;</span></code>
          to indicate that it is a class template.
        </li>
<li class="listitem">
          If a name refers to a function-like macro, it is specified like this:
          <code class="computeroutput"><span class="identifier">MACRO</span><span class="special">()</span></code>;
          that is, it is uppercase in code font and its name is followed by <code class="computeroutput"><span class="special">()</span></code> to indicate that it is a function-like
          macro. Object-like macros appear without the trailing <code class="computeroutput"><span class="special">()</span></code>.
        </li>
<li class="listitem">
          Names that refer to <span class="emphasis"><em>concepts</em></span> in the generic programming
          sense are specified in CamelCase.
        </li>
</ul></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
        In addition, notes such as this one specify non-essential information that
        provides additional background or rationale.
      </p></td></tr>
</table></div>
<p>
      Finally, you can mentally add the following to any code fragments in this document:
    </p>
<pre class="programlisting"><span class="comment">// Include all of Proto</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">proto</span><span class="special">/</span><span class="identifier">proto</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="comment">// Create some namespace aliases</span>
<span class="keyword">namespace</span> <span class="identifier">mpl</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpl</span><span class="special">;</span>
<span class="keyword">namespace</span> <span class="identifier">fusion</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">fusion</span><span class="special">;</span>
<span class="keyword">namespace</span> <span class="identifier">proto</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">proto</span><span class="special">;</span>

<span class="comment">// Allow unqualified use of Proto's wildcard pattern</span>
<span class="keyword">using</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">_</span><span class="special">;</span>
</pre>
</div>
<div class="footnotes">
<br><hr style="width:100; text-align:left;margin-left: 0">
<div id="ftn.boost_proto.preface.f0" class="footnote"><p><a href="#boost_proto.preface.f0" class="para"><sup class="para">[33] </sup></a>
        See <a href="http://en.wikipedia.org/wiki/Expression_templates" target="_top">Expression
        Templates</a>
      </p></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: December 02, 2021 at 06:54:13 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost/property_tree/xml_parser/write_1_3_33_10_11_1_1_1_4.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="proto/users_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
